package leetcode.editor.cn;

import java.util.HashMap;
import java.util.Map;

public class _1_TwoSum {
    public static void main(String[] args) {
        Solution solution = new _1_TwoSum().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            int[] res = {-1, -1};
            Map<Integer, Integer> map = new HashMap<>();
            map.put(nums[0], 0);
            for (int i = 1; i < nums.length; i++) {
                if (map.containsKey(target - nums[i])) {
                    res[0] = map.get(target - nums[i]);
                    res[1] = i;
                    break;
                }
                map.put(nums[i], i);
            }
            return res;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}